package com.dtx.controller;

import com.dtx.anno.ApiLog;
import com.dtx.controller.in.EditUserParam;
import com.dtx.controller.in.LoginUserParam;
import com.dtx.controller.in.RegisterUserParam;
import com.dtx.msg.ResultMsg;
import com.dtx.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

//@Api(tags = "BeetlSQL用户实体类接口")
@RestController
@RequestMapping("/beetl/user")
public class UserController {

    @Autowired
    private IUserService userService;

    @PostMapping("/findAll")
    //@ApiOperation("查询出所有用户")
    @ApiLog("查询出所有用户")
    public ResultMsg findAll(){
        ResultMsg msg = userService.findAll();
        return msg;
    }

    @PostMapping("/findByParam")
    //@ApiOperation("根据参数查询出用户信息")
    @ApiLog("根据参数查询出用户信息")
    public ResultMsg findByParam(@RequestBody EditUserParam param){
        ResultMsg msg = userService.findByParam(param);
        return msg;
    }

    @PostMapping("/register")
    //@ApiOperation("用户注册")
    @ApiLog("用户注册")
    public ResultMsg register(@RequestBody RegisterUserParam param){
        ResultMsg msg = userService.register(param);
        return msg;
    }

    @PostMapping("/login")
    //@ApiOperation("用户登录")
    @ApiLog("用户登录")
    public ResultMsg login(@RequestBody @Validated LoginUserParam param){
        ResultMsg msg = userService.login(param);
        return msg;
    }

    @PostMapping("/mdQueryUser")
    //@ApiOperation("md文件查询用户")
    @ApiLog("md文件查询用户")
    public ResultMsg mdQueryUser(@RequestBody EditUserParam param){
        ResultMsg msg = userService.mdQueryUser(param);
        return msg;
    }

}
